import java.util.Random;
import java.util.Scanner;

public class random1 {
    public static float random(){
        System.out.println("请输入要生成的随机数的个数：");
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

        System.out.println("生成的随机数为：");

        float randomSum = 0;
        for (int i = 0; i < n; i++) {
            Random random = new Random();
            float temp = random.nextInt(0,100);
            float randomNum = temp / 100;
            randomSum += randomNum;

            System.out.printf("%.2f    ",randomNum);
        }
        return randomSum;
    }
    public static void main(String[] args) {
        float randomSum = random();

        System.out.println();
        System.out.printf("生成的随机数的和为：%.2f",randomSum);
    }
}
